package ca.kooki.codesnippet.views;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.*;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.SWT;

import ca.kooki.codesnippet.Activator;
import ca.kooki.codesnippet.StatisticSummary;

public class StatisticsSummaryView extends ViewPart {
  
  //```````````````````````
  // MEMBER VARIABLES
  //```````````````````````
  
  public Composite parent;
  public Browser browser;
  public String innerHtml;
  
  //```````````````````````
  // CONSTRUCTOR
  //```````````````````````
  
  public StatisticsSummaryView()
  {
    init();
  }
  
  private void init()
  {
    innerHtml = "";
  }
  
  //```````````````````````
  // INTERFACE
  //```````````````````````
  
  public void createPartControl(Composite parent) 
  {
    initLayout(parent);
  }

  public void initLayout(Composite parent)
  {
    this.parent = parent;
    browser = new Browser(parent,SWT.NONE);
    setFocus();
  }

  public void setFocus() {
    StatisticSummary summary = Activator.getDefault().getRepository().getStatistics();
    innerHtml =  summary.toHtml();
    browser.setText(innerHtml);
  }

  
  //```````````````````````
  // PRIVATE METHODS
  //```````````````````````

}